#define _CRT_SECURE_NO_WARNINGS	

class Solution {
public:
    string compressString(string s)
    {
        string str;
        int len1 = s.size();
        string::iterator front = s.begin();
        string::iterator end = s.begin();
        string::iterator judge = s.end();
        int find = 1;
        int count = 0;
        while (front < judge)
        {
            if (find)
            {
                str += *front;
                find = 0;
                count++;
            }
            else
            {
                if (*front != *end)
                {
                    end = front;
                    str += to_string(count);
                    count = 1;
                    str += *front;
                }
                else
                {
                    count++;
                }
            }
            front++;
        }
        str += to_string(count);
        int len2 = str.size();
        if (len1 <= len2)
            return s;
        else
            return str;
    }
};